package com.sport.controller;

import com.sport.entity.SysPermission;
import com.sport.service.SysPermissionService;
import com.sport.utils.QueryInfo;
import com.sport.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "权限数据")
@RequestMapping("/system/permission")
public class SysPermissionController {

    @Autowired
    SysPermissionService sysPermissionService;

    @ApiOperation(value = "查询权限信息")
    @PostMapping("/findPage")
    public Result findPage(@RequestBody QueryInfo queryInfo) {
        return sysPermissionService.findPage(queryInfo);
    }

    @ApiOperation(value = "添加权限信息")
    @PostMapping("/insert")
    public Result insert(@RequestBody SysPermission  permission) {
        return sysPermissionService.insert(permission);
    }

    @ApiOperation(value = "删除权限信息")
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable("id") Long id) {
        return sysPermissionService.delete(id);
    }

    @ApiOperation(value = "修改权限信息")
    @PostMapping("/update")
    public Result update(@RequestBody SysPermission permission) {
        return sysPermissionService.update(permission);
    }

    @ApiOperation(value = "查看所有的权限")
    @GetMapping("/findAll")
    public Result finAll(){
        return sysPermissionService.findAll();
    }


}
